home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Creating an OpenDoc file?
- Sent: 9/13/96 4:24 PM
- Received: 9/13/96 4:24 PM
- From: mlanett@meer.net (Mark Lanett)
- Reply-To: ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List
-
-
- >I have caught the "Save A Copy" command and done my own Save As dialog and
- >can now output TEXT files. Now I would like to output OpenDoc documents
- >like CyberDog 1.1. Is there a way to redirect command and bypass the
- >default Save A Copy dialog? If not, how can I setup the file so that it has
- >all the right OpenDoc stuff in it, along with my data?
-
- What do you mean by "like Cyberdog 1.1"? Are you implementing a CD display
- part (navor-aware), or you just want a Save As command in your non-CD part?
-
- If you are *not* writing a CD part then this is easy. You may wish to look
- at the OD source code for RealShell::SaveACopy (RlShell.cpp), but it boils
- down to this:
-
-
- TempPlatformFile file = new PlatformFile();
- file->Specify(&reply.sfFile);
- ODSaveACopyOfDraft (ev, session, draft, file);
-
- If your part is CD navigator-aware, things are harder. This is because the
- way CD save as works, you are trying to save your (embedded) part out as
- the new root part of a new document, but in the current draft the root part
- is the CD navigator. Therefore cloning the draft doesn't work. ODF R2 has
- some Save As code but I punted on this at the time. This is my work in
- progress (it'll be posted to the web page once it's done).
-
- FW_CAcquiredODContainer fc = ::CreateFileContainer (ev, session, &reply.sfFile);
- FW_CAcquiredODDocument doc = fc->AcquireDocument (ev, kODDefaultDocument);
- FW_CAcquiredODDraft d = doc->AcquireBaseDraft (ev, kODDPExclusiveWrite);
- FW_CAcquiredODStorageUnit c = d->CreateStorageUnit (ev);
-
- FW_CAcquiredODStorageUnit p = d->AcquireDraftProperties (ev);
- ODSetStrongSURefProp (ev, p, kODPropRootPartSU, kODStrongStorageUnitRef,
- c->GetID(ev));
-
- c->AddProperty (ev, kODPropContents);
- // now you have to externalize your contents to this storageunit
-
- This snippet will result in an incomplete document, without a frame or
- window storageunit. This is ok for leaf parts but it won't if you are
- externalizing an embedding part.
-
- Both of these snippets leave out the resources (CODE, SIZE, etc). This
- should be ok unless you really need more process memory when the new
- document is launched.
-
-
- --
- Mark Lanett <mlanett@meer.net>
- Have a bajillion brilliant Jobsian lithium licks